package j15;

import cn.hutool.core.thread.ThreadUtil;

import java.util.concurrent.locks.LockSupport;

/**
 * @author chengshuai
 * @date 2021/5/4 22:35
 */
public class LockSupportDemo {

    public static void main(String[] args) {
        Thread a = new Thread(() -> {
            ThreadUtil.sleep(3000);
            System.out.println(Thread.currentThread().getName() + "\t" + "---come in");
            LockSupport.park();
            LockSupport.park();
            System.out.println(Thread.currentThread().getName() + "\t" + "---执行结束");
        }, "A");
        a.start();

        new Thread(() -> {
            LockSupport.unpark(a);
            LockSupport.unpark(a);
            System.out.println(Thread.currentThread().getName() + "\t" + "---执行结束");
        }, "B").start();

    }
}
